package com.v1.video.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.umeng.analytics.MobclickAgent;
import com.v1.video.R;
import com.v1.video.fragment.FragmentStarFans;
import com.v1.video.fragment.MyLoginSubscribeFragment;

/**
 * 我的订阅
 * 
 * @author fengtao
 */
public class MyLoginSubscribeActivity extends BaseActivity implements
		OnClickListener {

	private final String TAG = "MyLoginSubscribeActivity";
	private TextView mTvTitle;
	private String title = "";
	MyLoginSubscribeFragment mFragment;
	FragmentStarFans mFragmentFans;
	public static final int STATUS_DELETE_BTN = 0x0001;
	public static final int STATUS_DELETE_UPDATA_NUM = 0x0002;
	public static final int STATUS_DELETE_CANCEL = 0x0003;
	/** 用以标记是视频还是收藏 0视频，1收藏 */
	public int flag = 0;
	public static final int FLAG_SUBSCRIBE = 0;// 订阅
	public static final int FLAG_FANS = 1;// 粉丝
	public static final int FLAG_FANS_STAR = 2;// 明星粉丝
	public static String strFlag = "strFlag";
	private String userId = "";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_login_subscribe);
	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub
		mTvTitle = (TextView) this.findViewById(R.id.tv_title);
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub
		Intent intent = this.getIntent();
		title = intent.getStringExtra("title");
		flag = intent.getIntExtra(strFlag, FLAG_SUBSCRIBE);
		userId = intent.getStringExtra("userId");
		mTvTitle.setText(title);
		FragmentManager mFragmentManager = this.getSupportFragmentManager();
		if (flag == FLAG_FANS_STAR) {
			mFragmentFans = new FragmentStarFans(userId, flag);
			mFragmentManager.beginTransaction()
					.replace(R.id.lay_content, mFragmentFans).commit();
		} else {
			mFragment = new MyLoginSubscribeFragment(handler, flag);
			mFragmentManager.beginTransaction()
					.replace(R.id.lay_content, mFragment).commit();
		}
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		MobclickAgent.onPageEnd("我的" + title + "页");
		MobclickAgent.onPause(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		MobclickAgent.onPageStart("我的" + title + "页");
		MobclickAgent.onResume(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.lay_result:
			this.finish();
			break;
		default:
			break;
		}
	}

	@Override
	protected void setListener() {
		// TODO Auto-generated method stub
		findViewById(R.id.lay_result).setOnClickListener(this);
	}

	private Handler handler = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
			switch (msg.what) {
			case STATUS_DELETE_BTN:

				break;
			case STATUS_DELETE_UPDATA_NUM:
				break;
			case STATUS_DELETE_CANCEL:

				break;
			default:
				break;
			}
		}

	};

}
